import { createStore, compose, applyMiddleware } from 'redux'
import reducer from './reducer'
import thunk from 'redux-thunk'
import clientAxios from '../client/request'
import serverAxios from '../server/request'

//浏览器中添加redux-dev工具
export const getStore = (req) =>{
  return createStore(reducer, applyMiddleware(thunk.withExtraArgument(serverAxios(req))));  //中间件使用
}

export const getClientStore = () =>{
  const defaultState = window && window.context.state//数据进行脱水
  return createStore(reducer, defaultState, applyMiddleware(thunk.withExtraArgument(clientAxios)));  //中间件使用
}